package com.eptok.gw.szcups.cups.handler;

import org.apache.mina.core.service.IoHandlerAdapter;
import org.apache.mina.core.session.IoSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import ys8583.parse.IOMessage;

import com.eptok.gw.szcups.common.GateWayConstant;
import com.eptok.gw.szcups.cups.busi.ActiveBusiFactory;
import com.eptok.gw.szcups.cups.busi.CupsBusiInterface;
import com.eptok.gw.szcups.cups.busi.PassiveBusiFactory;
import com.solab.iso8583.common.ByteUtil;

/**
 *@author:heqishan, Email:heqishan@gmail.com
 *2013-3-24 下午06:19:25
 */
public class ActiveMerServerHandler extends IoHandlerAdapter {
	
	private static final Logger log = LoggerFactory.getLogger(ActiveMerServerHandler.class);

	
	private String handlerName;
	public ActiveMerServerHandler(String handlerName){
		this.handlerName = handlerName;
	}
	
	@Override
	public void messageReceived(IoSession session, Object message)
			throws Exception {
		IOMessage ioMessage = (IOMessage) message;
		log.info(handlerName + "接收数据(不含长度):" + ByteUtil.BinaryToHexString(ioMessage.toGetByte()));
		log.info(handlerName + "接收数据:" + ioMessage.toGetBitmapStr());
		//从业务工厂获取具体业务处理类
		CupsBusiInterface busiHandler = ActiveBusiFactory.getBusiInstance((String)ioMessage.getReqMessageID());
		busiHandler.dobusiness(ioMessage);
	}

}
